class EventPosition {
  String name
  String description
  Date startDate
  Date endDate
  String location
  int numberOfVolunteers
  // event positions are deleted when events are deleted
  static mapping = {
    cache true
  }

  static belongsTo = Event
  static hasMany = [volunteers: Volunteer]

  static constraints = {
    name(blank: false)
    description(blank: false)
    numberOfVolunteers(blank: false, min: 1)
    startDate(nullable: true)
    endDate(nullable: true)
  }

  String toString() {
    name
  }

  boolean equals(o) {
    if (this.is(o)) return true;
    if (!o || getClass() != o.class) return false;

    EventPosition position = (EventPosition) o;

    if (name != position.name) return false;
    if (description != position.description) return false;
    if (startDate != position.startDate) return false;
    if (endDate != position.endDate) return false;
    if (location != position.location) return false;

    return true;
  }

  int hashCode() {
    int result;
    result = (name ? name.hashCode() : 0);
    result = 31 * result + (description ? description.hashCode() : 0);
    result = 31 * result + (startDate ? startDate.hashCode() : 0);
    result = 31 * result + (endDate ? endDate.hashCode() : 0);
    result = 31 * result + (location ? location.hashCode() : 0);
    return result;
  }
}
